<template>
  <div class="printForm">
    <div class="area-header">
      <span class="area-header-title">{{ $t('申请单') }}</span>
    </div>
    <table class="printTable">
      <tr>
        <td class="tit">{{ $t('申请标题') }}</td>
        <td colspan="3">{{ form.actTitle }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('申请人') }}</td>
        <td>{{ form.applicantName }}</td>
        <td class="tit">{{ $t('申请时间') }}</td>
        <td>{{ parseTime(form.applicationTime) }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('申请部门') }}</td>
        <td>{{ form.deptName }}</td>
        <td class="tit">{{ $t('联系电话') }}</td>
        <td>{{ form.phone }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('选择需要销假的休假申请标题') }}</td>
        <td colspan="3">{{ form.vacationActTitle }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('休假时间') }}</td>
        <td>{{ parseTime(form.startDate) }} / {{ parseTime(form.endDate) }}</td>
        <td class="tit">{{ $t('实际申请天数') }}</td>
        <td>{{ form.vacationDay }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('工作交接人') }}</td>
        <td><UserSelect v-model="form.workUser" /></td>
        <td class="tit">{{ $t('去除节假日休假天数') }}</td>
        <td>{{ form.removeHoliday }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('通知人员') }}</td>
        <td colspan="3"><UserSelect v-model="form.noticeUsers" multiple /></td>
      </tr>
    </table>

    <div v-if="form.oaVacationDetails && form.oaVacationDetails.length > 0">
      <div class="area-header">
        <span class="area-header-title">{{ $t('休假明细') }}</span>
      </div>
      <table class="previewTable">
        <thead>
          <th>{{ $t('申请休假类型') }}</th>
          <th>{{ $t('实际剩余天数') }}</th>
          <th>{{ $t('本次申请天数') }}</th>
          <th>{{ $t('本次实际天数') }}</th>
        </thead>
        <tbody>
          <tr v-for="(v, ind) in form.oaVacationDetails" :key="ind">
            <td>
              {{ v.type }}
            </td>
            <td>{{ v.remainDay }}</td>
            <td>{{ v.vacationDay }}</td>
            <td>{{ v.actualVacationDay }}</td>
          </tr>
        </tbody>
      </table>

    </div>

    <!-- 附件列表 -->
    <FileView :list.sync="form.fileList" data-type="hr_quit" :btn-show="!otherBtnHide" />
  </div>
</template>

<script>
import { getOaLeaveOff } from '@/api/oa/leave/oaLeaveOff'
export default {
  data() {
    return {
      form: {
        fileList: []
      },
      buttonShow: true,
      otherBtnHide: false
    }
  },
  created() {
    this.$bus.$emit('async_done')
  },
  methods: {
    // 初始化数据
    init(data) {
      // 查询销假数据
      if (data != null && data.id !== undefined) {
        getOaLeaveOff(data.id).then(response => {
          this.form = response.data
        })
      }
    }
  }
}
</script>
